package com.cos.web.controller;

import com.cos.entity.User;
import org.apache.taglibs.standard.tag.common.sql.DataSourceUtil;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @author: COS
 * @time: 2021/5/19 14:51
 * @description:
 */
@Controller
@RequestMapping("/emp")
public class EmpController {

    @RequestMapping("/login")
    public String login(String ename, String pwd, Model model){
        System.out.println("ename:"+ename+"----pwd:"+pwd);
        if (ename.equals("admin")&&pwd.equals("admin")) {
            System.out.println("登录成功");
            User user = new User();
            user.setName("admin");
            //把数据设置到request作用域中
            model.addAttribute("user",user);
            return "index";
        }else{
            //重定向
            return "redirect:/login.jsp";
        }

    }




}
